package cluster

import (
	"kubeInstall/server/models"
	"kubeInstall/server/models/storageplugin"
)

//安装节点的数据库模型
type HostNameAndIP struct {
	HostName string `json:"host_name"`
	Ip       string `json:"ip"`
}

//集群配置的数据库模型
type Cluster struct {
	ID             string `json:"id" gorm:"primary_key;column:cluster_id"`
	Status         string `json:"status"`
	ClusterName    string `json:"cluster_name"`
	DomainName     string `json:"domain_name"`
	ClusterVersion string `json:"cluster_version" grom:"not null"`
	ClusterType    string `json:"cluster_type"`
	MaxPodNum      int    `json:"max_pod_num"`
	ApiServer      string `json:"api_server"`
	VipServer      string `json:"vip_server"`
	RepoName       string `json:"repo_name"`
	//network 配置
	PodCIDR     string `json:"pod_cidr" gorm:"column:pod_cidr;not null"`
	SvcCIDR     string `json:"svc_cidr" gorm:"column:svc_cidr;not null"`
	ProxyMode   string `json:"proxy_mode"`
	NetworkType string `json:"network_type"`

	//存储配置
	StorageType   string                    `json:"storage_type"`
	StoragePlugin *storageplugin.StorageNFS `json:"storage_plugin" gorm:"save_associations:false"`
	//host配置
	HostNameMap    []HostNameAndIP       `json:"-" gorm:"save_associations:false"`
	MasterNode     []Host                `json:"master_node" gorm:"save_associations:false"`
	WorkerNode     []Host                `json:"worker_node" gorm:"save_associations:false"`
	//Master0Handler *install.AsyncHandler `json:"-"`

	//集群插件配置
	MonitorEnable             bool `json:"monitor_enable"`
	LogEnable                 bool `json:"log_enable"`
	IngressEnable             bool `json:"ingress_enable"`
	DnsCacheEnable            bool `json:"dns_cache_enable"`
	NodeProblemDetectorEnable bool `json:"node_problem_detector_enable"`
	MetricServerEnable        bool `json:"metric_server_enable"`

	models.BaseModel
}

func (c Cluster) TableName() string {
	return "t_install_cluster"
}
